package test.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Created by 张少昆 on 2017/12/25.
 */
@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception{
        http
                .authorizeRequests()
                // .antMatchers("/resources/**", "/signup", "/about").permitAll()
                // .antMatchers("/admin/**").hasRole("ADMIN")
                // .antMatchers("/db/**").access("hasRole('ADMIN') and hasRole('DBA')")
                .anyRequest().authenticated()
                .and()
                .formLogin()  //https://springcloud.cc/spring-security-zhcn.html#jc-form
                .loginPage("/login")
                .permitAll(); //允许访问/login页面啦
    }


}
